package cn.xiongxf.system.service.impl;

import cn.xiongxf.basic.service.impl.BaseServiceImpl;
import cn.xiongxf.system.domain.SystemDictionaryType;
import cn.xiongxf.system.mapper.SystemDictionaryDetailMapper;
import cn.xiongxf.system.mapper.SystemDictionaryTypeMapper;
import cn.xiongxf.system.service.SystemDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SystemDictionaryTypeServiceImpl extends BaseServiceImpl<SystemDictionaryType> implements SystemDictionaryTypeService {
    @Autowired
    private SystemDictionaryTypeMapper systemDictionaryTypeMapper;
    @Autowired
    private SystemDictionaryDetailMapper systemDictionaryDetailMapper;

    @Transactional
    @Override
    public void del(Long id) {
        // 先删明细，再删类型（先子后父）
        systemDictionaryDetailMapper.removeByTypeId(id);
        systemDictionaryTypeMapper.remove(id);
    }

    @Transactional
    @Override
    public void patchDel(List<Long> ids) {
        // 先删明细，再删类型（先子后父）
        systemDictionaryDetailMapper.patchRemoveByTypeId(ids);
        systemDictionaryTypeMapper.patchRemove(ids);
    }
}
